<?php

namespace app\admin\controller;

use library\Controller;
use think\Db;

/**
 * 团队收益记录
 * Class Item
 * @package app\admin\controller
 */
class TeamProfit extends Controller
{
    /**
     * 绑定数据表
     * @var string
     */
    protected $table = 'LcTeamProfit';

    /**
     * 团队收益记录
     * @auth true
     * @menu true
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function index()
    {
        $this->title = '团队收益记录';
        $query = $this->_query($this->table)->alias('i')->field('i.*,u.username,u2.username pusername');
        $query = $query->join('lc_user u','i.uid=u.id')->join('lc_user u2','i.puid=u2.id')->equal('u.username#u_username,u2.username#pusername')->valueBetween('i.time_date#i_time',' - ')->order('i.time_date desc')->page();
    }

    /**
     * 数据列表处理
     * @param array $data
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    protected function _index_page_filter(&$data)
    {
        // $pusers = [];
        // foreach($data as &$vo){
        //     if(!isset($pusers[$vo['puid']])){
        //         $pusers[$vo['puid']] = Db::name("lc_user")->field('id,username')->find($vo['puid']);
        //     }
        //     if($pusers[$vo['puid']]){
        //         $vo['pusername'] = $pusers[$vo['puid']]['username'];
        //     }
        // }
    }
}
